package com.atwl.school.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atwl.school.entity.StockEntity;
import com.atwl.school.service.StockService;
import com.atwl.school.common.utils.PageUtils;
import com.atwl.school.common.utils.R;


/**
 * 
 *
 * @author liangli
 * @email liangli@qq.com
 */
@RestController
@RequestMapping("school/stock")
public class StockController {
    @Autowired
    private StockService stockService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = stockService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{proId}")
    public R info(@PathVariable("proId") Integer proId){
		StockEntity stock = stockService.getById(proId);

        return R.ok().put("stock", stock);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody StockEntity stock){
		stockService.save(stock);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody StockEntity stock){
		stockService.updateById(stock);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] proIds){
		stockService.removeByIds(Arrays.asList(proIds));

        return R.ok();
    }

}
